package com.taihua_tech.basic.util;

import java.io.File;

import javax.servlet.http.HttpServletRequest;

public class AttachmentPathUtil {
	public static String getAttachmentUploadPath(HttpServletRequest request) {
		String path = request.getSession().getServletContext().getRealPath("/");
		path=path.substring(0,path.lastIndexOf(System.getProperty("file.separator"))); 
		path=path.substring(0,path.lastIndexOf(System.getProperty("file.separator")));
		File file=new File(path+System.getProperty("file.separator")+"attachment");
		file.mkdir();
		file=new File(file.getAbsolutePath()+System.getProperty("file.separator")+request.getContextPath());
		file.mkdir();
		return file.getAbsolutePath()+System.getProperty("file.separator");
	}
	
	public static String getAttachmentNetPath(HttpServletRequest request) {
		String url= request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/"+"attachment"+request.getContextPath()+"/";
		return url;
	}
}
